home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Libraries / Gestalt.Lib < prev    next >
Encoding:
Text File  |  1993-12-17  |  21.7 KB  |  756 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Gestalt.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.12>     12/8/93    KTA        FormLongNumber() - Removed quitting the MathTool - if multiple
  19. #                                    targets are running the tool will not be available.
  20. #     <1.0.9>     12/3/93    KTA        MachineState now returns logical and physical memory in bytes,
  21. #                                    added FormLongNumber() task.
  22. #     <1.0.8>     12/2/93    KTA        Removed globals isOff, IsOn, VirtualMemory, notAvail, etc.
  23. #     <1.0.7>     12/2/93    KTA        Added tasks GestaltSystemArchitecture() and IsPowerPC().  Added
  24. #                                    SystemArchitecture as MachineState() target descriptor.
  25. #     <1.0.6>    11/30/93    ML        Added ReturnMachineName parameter to GestaltMachineType, now
  26. #                                    returns Machine umber by default
  27. #     <1.0.5>      8/9/93    KTA        MachineState() - Updates for new Pheonix data format .
  28. #     <1.0.4>     7/19/93    KTA        InitOnTarget had a syntax error that wasn't caught.
  29. #     <1.0.3>     7/15/93    KTA        Changed the name of some tasks so they wouldn't conflict with
  30. #                                    Gestalt.vulib, changed error checking in InitOnTarget(), removed
  31. #                                    SystemVersion() and MachineName().
  32. #     <1.0.2>      6/8/93    NAGA        unmark tasks that are not published
  33. #        <1.0.1>     5/21/93    NAGA        Adding header and porting old files to follow new standards
  34. #
  35. # ****************************************************************************
  36. #
  37.  
  38. ########################################################################
  39. #                            External libraries 
  40. #=======================================================================
  41. Libraries "OnTarget.Lib", "MathTool.vulib";
  42.  
  43.  
  44.     
  45. ##################################################################################
  46. #                        Check32Bit()
  47. #=======================================================================
  48. # Author:        GS
  49. # Description:    This routine will check the state of 32 bit addressing,
  50. #                and returns the value.
  51. # Parameters:    None
  52. # Returns:        Values
  53. #                On        :=  1
  54. #                Off        :=  0
  55. #                not Avail :=  -1
  56. #                GestaltError
  57. #                in the first item a value described above.  The second item is a text 
  58. #                string description of the value.
  59. #=======================================================================
  60. # History:
  61. #
  62. ##################################################################################
  63. Task Check32Bit()
  64. begin
  65.     theResult := LowWordOfAnswer(gestalt( 'addr' ));
  66.      
  67.     if (theResult & (1 << 0))
  68.         retVal := {1, "32 bit addressing is ON"};
  69.     
  70.     else if (theResult & (1 << 2))
  71.         retVal := {0, "32 bit addressing is available but turned OFF"};
  72.  
  73.     else if not ((theResult & (1 << 0)) or (theResult & (1 << 1)) or (theResult & (1 << 2)))
  74.         retVal := {-1, "32 bit addressing is not available on this machine"};
  75.  
  76.     if (gestRes[1]) 
  77.         retVal := {gestRes[1], "Gestalt Error  (-5550 is gestalt unavailable error)"};
  78.  
  79.     return retVal;
  80. end;
  81.  
  82.  
  83.  
  84. ##################################################################################
  85. #                        CheckVM()
  86. #=======================================================================
  87. # Author:        GS
  88. # Description:    Checks to see if VM is turned on.
  89. #
  90. # Parameters:    None
  91. # Returns:        On   :=  1
  92. #                Off  :=     0
  93. #                not Avail :=  -1
  94. #                GestaltError
  95. # if VM is on gestalt('vm  ') returns a 1
  96. # any other case (not available, not turned on is a 0)
  97. #=======================================================================
  98. # History:
  99. # KTA 12/02/93 Removed isOff, IsOn, VirtualMemory, notAvail, etc.
  100. ##################################################################################
  101. TASK CheckVM()
  102. begin
  103.     vmValue := LowWordOfAnswer(gestalt( 'vm  ' ));
  104.  
  105.     if (vmValue = 0)
  106.     begin
  107.         theMMU    := LowWordOfAnswer(gestalt( 'mmu ' ));
  108.         if(theMMU > 1)
  109.             retVal := {0, "VM is available and OFF"};
  110.         else 
  111.             retVal := {-1, "VM is NOT available on this machine"};
  112.     end;
  113.         
  114.     else if (vmValue & (1 << 0))
  115.         retVal := {1, "VM is ON"};
  116.     
  117.     errorCode := gestRes[1];    
  118.     if (errorCode) 
  119.         retVal := {errorCode, "Gestalt Error  (-5550 is gestalt unavailable error)"};
  120.     
  121.     return retVal;
  122. end;        
  123.                 
  124.     
  125.     
  126.  
  127. ##################################################################################
  128. #                        CheckCache()
  129. #=======================================================================
  130. # Author:        GS
  131. # Description:    Checks to see if caching is available and turned on, and returns 
  132. #                a value.
  133. #
  134. # Parameters:    None
  135. # Returns:        On         :=  1
  136. #                Off        :=  0
  137. #                not Avail :=  -1
  138. #                GestaltError
  139. #=======================================================================
  140. # History:
  141. #
  142. ##################################################################################
  143. TASK CheckCache()
  144. begin    
  145.     if (GestaltProcessorType() = '68040')
  146.     begin
  147.         if(OnTargetInit())
  148.         begin
  149.             toolRes := OnTarget( 'CacheTest' )[2];
  150.             
  151.             if(toolRes = 1)
  152.                 retVal := {1, "040 Caches are ON"};
  153.             
  154.             if(toolRes = 2)
  155.                 retVal := {-1, "This isn't an '040, caching unavailable"};
  156.                 
  157.             if(toolRes = 0)
  158.                 retVal := {0, "040 Caches are OFF"};
  159.     
  160.             OnTarget('Quit');
  161.         end;
  162.         else
  163.             retVal := {-2,"We Don't know, can't launch OnTarget to find out"};
  164.  
  165.     end;
  166.     else         
  167.         retVal := {-1, "This isn't an '040, caching unavailable"};
  168.  
  169.     return retVal;
  170. end;
  171.  
  172.  
  173.  
  174. ##################################################################################
  175. #                        FileShare()
  176. #=======================================================================
  177. # Author:        GS
  178. # Description:    Checks to see if fileshare was installed and whether its switched on.
  179. #
  180. # Parameters:    None
  181. # Returns:        On       :=   1
  182. #                Off      :=   0
  183. #                not Avail:=  -1
  184. #                GestaltError
  185. #=======================================================================
  186. # History:
  187. #
  188. ##################################################################################
  189. TASK FileShare()
  190. begin    
  191.     if(OnTargetInit())
  192.     begin
  193.         theResult := OnTarget( 'FileShare' )[2];
  194.     
  195.         if(theResult = 0)
  196.             retVal := {0, "FileSharing is available but NOT ENABLED"};
  197.             
  198.         else if(theResult = 1)
  199.             retVal  := {1, "FileSharing is ON"};
  200.             
  201.         else if(theResult = 2)
  202.             retVal  := {-1, "FileSharing is not available on theis machine"};
  203.             
  204.         else
  205.             retVal := {-1, "Error checking status of Filesharing"};
  206.         
  207.         OnTarget('Quit');
  208.     end;
  209.     else 
  210.         retVal := {-2,"We Don't know, can't launch OnTarget to find out"};
  211.     
  212.     return(retVal);
  213. end;
  214.  
  215.  
  216.  
  217. ##################################################################################
  218. #                        LowWordOfAnswer()
  219. #=======================================================================
  220. # Author:        GS
  221. # Description:    Returns second item of a list.
  222. #
  223. # Parameters:    None
  224. # Returns:        second item of a list
  225. #=======================================================================
  226. # History:
  227. #
  228. ##################################################################################
  229. task LowWordOfAnswer(Answer)
  230. begin
  231.  
  232.     tempVal    := Answer[2];
  233.     retVal  := tempVal[2];
  234.  
  235.     return retVal;
  236. end;
  237.  
  238.  
  239. ##################################################################################
  240. #                        GestaltLongError()
  241. #=======================================================================
  242. # Author:        GS
  243. # Description:    Will return a longer error response in the form of a string.
  244. #
  245. # Parameters:    None
  246. # Returns:        String with error text
  247. #=======================================================================
  248. # History:
  249. #
  250. ##################################################################################
  251. task GestaltLongError(gestaltAnswer := {0,{0,0}})
  252. begin
  253.     kGestaltNoErr := 0;
  254.     kGestaltUnknownErr := -5550;
  255.     kGestaltUndefSelectorErr := -5551;
  256.  
  257.     gesErr := gestaltAnswer[1];
  258.     if gesErr = kGestaltNoErr
  259.         return "No error";
  260.     else if gesErr = kGestaltUnknownErr
  261.         return "Error: Could not obtain response";
  262.     else if gesErr = kGestaltUndefSelectorErr
  263.         return "Error: Undefined selector";
  264.     else
  265.         return "Error: Unknown error code: {gesErr}";
  266. end;
  267.  
  268.  
  269.  
  270.  
  271.  
  272. ##################################################################################
  273. #                        GestaltFPUType()
  274. #=======================================================================
  275. # Author:        Derived from Virtual User 2.0 Example libraries
  276. # Description:    Returns FPU type.
  277. #
  278. # Parameters:    None
  279. # Returns:        NoFPU
  280. #                68881
  281. #                68882
  282. #                68040
  283. #                unknFPU
  284. #=======================================================================
  285. # History:
  286. #
  287. ##################################################################################
  288. TASK GestaltFPUType()
  289. begin
  290.     gesAns := Gestalt('fpu ');
  291.     gesErr := gesAns[1];
  292.     if (not gesErr)
  293.     begin
  294.         fpuAns := gesAns[2][2];
  295.         if fpuAns = 0
  296.             return "NoFPU";
  297.         else if fpuAns = 1
  298.             return "68881";
  299.         else if fpuAns = 2
  300.             return "68882";
  301.         else if fpuAns = 3
  302.             return "68040FPU";
  303.         else
  304.             return "unknFPU";
  305.     end;
  306.     else
  307.         return GestaltLongError(gesAns);
  308. end;
  309.  
  310.  
  311.  
  312. ##################################################################################
  313. #                        GestaltMachineType()
  314. #=======================================================================
  315. # Author:        Derived from Virtual User 2.0 Example libraries
  316. # Description:    Checks machine being tested and returns string with Machine Type.
  317. #
  318. # Parameters:    None
  319. # Returns:        String with Machine Name (See list below)
  320. #=======================================================================
  321. # History:
  322. #    ML    11/30/93    Added ReturnMachineName parameter, now returns Machine
  323. #                    number by default
  324. ##################################################################################
  325. TASK GestaltMachineType(ReturnMachineName := 0)
  326. begin
  327.     gesAns := Gestalt('mach');
  328.     gesErr := gesAns[1];
  329.     if (not gesErr)
  330.     begin
  331.         machAns := gesAns[2][2];
  332.         if (ReturnMachineName)
  333.         begin
  334.             if machAns = 1
  335.                 return "Classic";
  336.             else if machAns = 2
  337.                 return "MacXL";
  338.             else if machAns = 3
  339.                 return "Mac512KE";
  340.             else if machAns = 4
  341.                 return "MacPlus";
  342.             else if machAns = 5
  343.                 return "MacSE";
  344.             else if machAns = 6
  345.                 return "MacII";
  346.             else if machAns = 7
  347.                 return "MacIIx";
  348.             else if machAns = 8
  349.                 return "MacIIcx";
  350.             else if machAns = 9
  351.                 return "MacSE030";
  352.             else if machAns = 10
  353.                 return "Portable";
  354.             else if machAns = 11
  355.                 return "MacIIci";
  356.             else if machAns = 13
  357.                 return "MacIIfx";
  358.             else if machAns = 17
  359.                 return "MacClassic";
  360.             else if machAns = 18
  361.                 return "MacIIsi";
  362.             else if machAns = 19
  363.                 return "MacLC";
  364.             else if machAns = 20
  365.                 return "Quadra900";
  366.             else if machAns = 21
  367.                 return "Powerbook170";
  368.             else if machAns = 22
  369.                 return "Quadra700";
  370.             else if machAns = 23
  371.                 return "ClassicII";
  372.             else if machAns = 24
  373.                 return "PowerBook100";
  374.             else if machAns = 25
  375.                 return "PowerBook140";
  376.             else if machAns = 26
  377.                 return "Quadra 950";
  378.             else
  379.                 return MachAns;
  380.         end; # if ReturnMachineName
  381.         else
  382.             return MachAns;
  383.     end; # if (not gesErr)
  384.     else
  385.         return GestaltLongError(gesAns);
  386. end;
  387.  
  388.  
  389. ##################################################################################
  390. #                        GestaltProcessorType()
  391. #=======================================================================
  392. # Author:        Derived from Virtual User 2.0 Example libraries
  393. # Description:    Returns the processor running on the test machine
  394. #
  395. # Parameters:    None
  396. # Returns:        68000
  397. #                68010
  398. #                68020
  399. #                68030
  400. #                68040
  401. #=======================================================================
  402. # History:
  403. #
  404. ##################################################################################
  405. TASK GestaltProcessorType()
  406. begin
  407.     gesAns := Gestalt('proc');
  408.     gesErr := gesAns[1];
  409.     if (not gesErr)
  410.     begin
  411.         procAns := gesAns[2][2];
  412.         if procAns = 1
  413.             return "68000";
  414.         else if procAns = 2
  415.             return "68010";
  416.         else if procAns = 3
  417.             return "68020";
  418.         else if procAns = 4
  419.             return "68030";
  420.         else if procAns = 5
  421.             return "68040";
  422.         else
  423.             return "unknProc";
  424.     end;
  425.     else
  426.         return GestaltLongError(gesAns);
  427. end;
  428.  
  429.  
  430.  
  431. ##################################################################################
  432. #                        GestaltMMUType()
  433. #=======================================================================
  434. # Author:        Derived from Virtual User 2.0 Example libraries
  435. # Description:    Will return the memory management unit type found operating on the target.
  436. #
  437. #
  438. # Parameters:    None
  439. # Returns:        NoMMU
  440. #                AMU
  441. #                68851
  442. #                68030MMU
  443. #                68040MMU
  444. #                unknMMUType
  445. #=======================================================================
  446. # History:
  447. #
  448. ##################################################################################
  449. TASK GestaltMMUType()
  450. begin
  451.     gesAns := Gestalt('mmu ');
  452.     gesErr := gesAns[1];
  453.     if (not gesErr)
  454.     begin
  455.         mmuAns := gesAns[2][2];
  456.         if mmuAns = 0
  457.             return "NoMMU";
  458.         else if mmuAns = 1
  459.             return "AMU";
  460.         else if mmuAns = 2
  461.             return "68851";
  462.         else if mmuAns = 3
  463.             return "68030MMU";
  464.         else if mmuAns = 4
  465.             return "68040MMU";
  466.         else
  467.             return "unknMMUType";
  468.     end;
  469.     else
  470.         return GestaltLongError(gesAns);
  471. end;
  472.  
  473.  
  474. ##################################################################################
  475. #                        GestaltLogicalRAMSize()
  476. #=======================================================================
  477. # Author:        Derived from Virtual User 2.0 Example libraries
  478. # Description:    Will return the amount of logical RAM located in a machine.
  479. #                (VM+RM)  
  480. #
  481. #
  482. # Parameters:    None
  483. # Returns:        an integer in megabytes.
  484. #=======================================================================
  485. # History:
  486. #
  487. ##################################################################################
  488. TASK GestaltLogicalRAMSize()
  489. begin
  490.     gesAns := Gestalt('lram');
  491.     gesErr := gesAns[1];
  492.     if (not gesErr)
  493.     begin
  494.         theHiWord := gesAns[2][1];
  495.         # Gestalt apparently has a problem reporting the full 8MB of physical memory
  496.         # on machines with no virtual memory enabled.  This will compensate.
  497.         return (theHiWord + 1) / 16;
  498.     end;
  499.     else
  500.         return GestaltLongError(gesAns);
  501. end;
  502.  
  503.  
  504. ##################################################################################
  505. #                        GestaltPhysicalRAMSize()
  506. #=======================================================================
  507. # Author:        Derived from Virtual User 2.0 Example libraries
  508. # Description:    Will return the amount of physical RAM located in a machine.
  509. #
  510. #
  511. # Parameters:    None
  512. # Returns:        an integer in megabytes.
  513. #=======================================================================
  514. # History:
  515. #
  516. ##################################################################################
  517. TASK GestaltPhysicalRAMSize()
  518. begin
  519.     gesAns := Gestalt('ram ');
  520.     gesErr := gesAns[1];
  521.     if (not gesErr)
  522.     begin
  523.         theHiWord := gesAns[2][1];
  524.         # Gestalt apparently has a problem reporting the full 8MB of physical memory
  525.         # on machines with no virtual memory enabled.  This will compensate.
  526.         return (theHiWord + 1) / 16;
  527.     end;
  528.     else
  529.         return GestaltLongError(gesAns);
  530. end;
  531.  
  532.  
  533. ##################################################################################
  534. #                        MachineState()
  535. #=======================================================================
  536. # Author:        GS
  537. # Description:    Returns a list of information concerning the state of the target 
  538. #                machine.
  539. #
  540. # Parameters:    None
  541. # Returns:        Gestalt Info
  542. #=======================================================================
  543. # History:
  544. # KTA    8/3/93    Rewrote - returns instead of prints info
  545. # KTA    12/3/93    Return logical and Physical memory in Bytes.
  546. ##################################################################################
  547. TASK MachineState(printMachineState := 0)
  548. begin
  549.     targetDesc := match[target];    
  550.     match[system v:?SysVersion];    
  551.     if(IsPowerPC())
  552.         sysa := 'PowerPC';
  553.     else
  554.         sysa := '68k';
  555.     
  556.     CPUType            := { "CPUType", GestaltProcessorType()};
  557.     MMUType         := { "MMUType", GestaltMMUType()};
  558.     FPUType         := { "FPUType", GestaltFPUType()};
  559.     MachineType     := { "MachineType", GestaltMachineType()};
  560.  
  561.     TargetsName        := { "TargetName", targetDesc.t};
  562.     AddrMode         := { "AddrMode", Check32Bit()[1]};
  563.     
  564.     ## logical Mem 
  565.     LogMem := FormLongNumber(Gestalt('lram')[2]);
  566.     if not (logMem)
  567.     begin
  568.         LogicalMemMb := GestaltLogicalRAMSize();
  569.         LogicalMemkBytes := LogicalMemMb*1024;
  570.         logMem := "{LogicalMemkBytes}000";
  571.     end;
  572.     LogicalMem        := { "LogicalMem",logMem };
  573.     
  574.     ## Physical Mem
  575.     PhysMem := FormLongNumber(Gestalt('ram ')[2]);
  576.     if not (PhysMem)
  577.     begin
  578.         PhysicalMemMb := GestaltPhysicalRAMSize();
  579.         PhysicalMemkBytes := PhysicalMemMb*1024;
  580.         PhysMem := "{PhysicalMemkBytes}000";
  581.     end;
  582.     PhysicalMem        := { "PhysicalMem",PhysMem};
  583.     VM                 := { "VM", CheckVM()[1]};
  584.     FileSharing        := { "FileShare", FileShare()[1]};    # Requires OnTarget
  585.     Caches             := { "Cache",    CheckCache()[1]};
  586.     MonitorBitDepth := { "BitDepth", targetDesc.s[1].p};
  587.     SystemVersion    := { "SysVersion", SysVersion};
  588.     SystemArch        := { "SystemArch", sysa};
  589.     
  590.     returnVal := {CPUType, MMUType, FPUType, MachineType, TargetsName, AddrMode, LogicalMem, PhysicalMem, VM, FileSharing, Caches, MonitorBitDepth, SystemVersion, SystemArch };
  591.     if (printMachineState)
  592.     begin
  593.         for each item in returnVal
  594.             println item[1], ":    ",item[2];
  595.     end;
  596.     
  597.     return(returnVal);
  598. end;
  599.         
  600.         
  601. #########################################################################
  602. #                 GestaltSystemArchitecture()
  603. #=======================================================================
  604. # Author:          Kevin Avoy
  605. # Description:    Makes a Gestalt call with selector of 'sysa' to determine if the
  606. #                target system is 68K or PowerPC
  607. # Parameters:    none
  608. # Returns:        0 - Selector not installed (older 68k)
  609. #                1 - Selector installed - target is 68k based not PowerPC
  610. #                2 - Selector installed - target is PowerPC based not 68k
  611. #=======================================================================
  612. # History:
  613. # KTA    12/01/93    Created
  614. ########################################################################
  615. TASK GestaltSystemArchitecture()
  616. begin    
  617.     gesAns := Gestalt('sysa');
  618.     #println gesAns;
  619.     if(GesAns[1] = -5551)    # Selector not installed (older 68k machine)
  620.         ReturnVal := 0;
  621.     else if (GesAns[1] = 0)
  622.     begin
  623.         if( GesAns[2][2] = 1)    # 68k system
  624.             returnVal := 1;
  625.         else if ( GesAns[2][2] = 2)    # PowerPC native system
  626.             returnVal := 2;
  627.         else
  628.             println "returnVal unknown - {gesAns}";
  629.     end;
  630.     else
  631.         println " - a unexpected gestalt error occured - {gesAns}";
  632.     
  633.     return(ReturnVal);    
  634. end;
  635.  
  636. #########################################################################
  637. #                 IsPowerPC()
  638. #=======================================================================
  639. # Author:          Kevin Avoy
  640. # Description:    Makes a call to ProcessorType() to determine if the
  641. #                target system is PowerPC or not
  642. # Parameters:    none
  643. # Returns:        0 - not PowerPC
  644. #                1 - PowerPC
  645. #=======================================================================
  646. # History:
  647. # KTA    12/01/93    Created
  648. ########################################################################
  649. TASK IsPowerPC()
  650. begin
  651.     returnVal := 0;
  652.     sysa := GestaltSystemArchitecture();
  653.     if(sysa = 2)
  654.         returnVal := 1;
  655.     return(returnVal);
  656. end;
  657.         
  658. #########################################################################
  659. #                     OnTargetInit()
  660. #========================================================================
  661. #
  662. # Author:        GS
  663. #
  664. # Description:    Initializes OnTarget
  665. # Parameters:    None
  666. # Returns:        1 - if OnTarget launched and initialized
  667. #                0 - if OnTarget could not launch
  668. #
  669. # Examples:        OnTargetInit()  
  670. #
  671. #========================================================================
  672. # History:
  673. # KTA 7/14/93    Changed error handling
  674. #########################################################################
  675. TASK OnTargetInit()
  676. begin
  677.     returnVal := 0;
  678.     IsError := OnTarget('Initialize',1);
  679.     if(IsError[1])        # Some Error
  680.     begin
  681.         errorString := IsError[3];
  682.         println "Ontarget initialization failed: ", errorString;
  683.     end;
  684.     else
  685.         returnVal := 1;
  686.  
  687.     return (returnVal);
  688. end;
  689.  
  690. #########################################################################
  691. #                        FormLongNumber(pHiLoList)
  692. #========================================================================
  693. # Author:        KTA
  694. # Description:    Forms a long (32 bit) numeric string from a high word 16-bit  
  695. #                number and a low word 16-bit number.
  696. # Parameters:    pHiLoList - list of two elements.
  697. #                    1st element is the hiWord number.
  698. #                    2nd element is the loWord number.
  699. # Returns:        returns a long (32 bit) numeric string
  700. #                0 - failure (some tool call probably failed.
  701. # Examples:        FormLongNumber({ 122,-2304 });
  702. # Assumptions:    
  703. #========================================================================
  704. # History:
  705. # KTA 12/3/93    Created
  706. # KTA 12/08/93    Removed quitting the MathTool - if multiple targets are running
  707. #                 the tool will not be available.
  708. #########################################################################
  709. Task FormLongNumber(pHiLoList := {})
  710. begin
  711.     returnVal := 0;
  712.     result := MathTool("Initialize", 0);  # true - launch on the host
  713.     if (result[1] <> 0 )
  714.     begin
  715.         println "MathTool could not be initialized";        # print error
  716.         println "Error ", result[1], ". ",  result[3] ;
  717.     end;
  718.     else
  719.     begin
  720.         HiWord := pHiLoList[1];
  721.         loWord := pHiLoList[2];
  722.         
  723.         if (loWord < 0 )            # if loWord is less than zero add 1 to high word
  724.             HiWord := HiWord + 1;
  725.             
  726.         TwoPower16 := MathTool("power", 2, 16);
  727.         if (TwoPower16[1] <> 0 )
  728.         begin
  729.             println "MathTool could not perform Power service";        # print error
  730.             println "Error ", TwoPower16[1], ". ",  TwoPower16[3] ;
  731.         end;
  732.         else
  733.         begin
  734.             HiWordXTwoPower16 := MathTool("ftimes", TwoPower16[2], HiWord);
  735.             if (HiWordXTwoPower16[1] <> 0 )
  736.             begin
  737.                 println "MathTool could not perform ftimes service";        # print error
  738.                 println "Error ", HiWordXTwoPower16[1], ". ",  HiWordXTwoPower16[3] ;
  739.             end;
  740.             else
  741.             begin
  742.                 LogicalMemInBytes := MathTool("fplus", HiWordXTwoPower16[2], loWord);
  743.                 if (LogicalMemInBytes[1] <> 0 )
  744.                 begin
  745.                     println "MathTool could not perform fplus service";        # print error
  746.                     println "Error ", LogicalMemInBytes[1], ". ",  LogicalMemInBytes[3] ;
  747.                 end;
  748.                 else
  749.                     returnVal := LogicalMemInBytes[2];
  750.             end;
  751.         end;
  752.         #MathTool("Quit"); # Can not quit - if multiple targets are running the tool will not be available
  753.     end;
  754.     return(returnVal);
  755. end;
  756.